Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
Here are the high-level changes...
thread_pool
that utilizes a pool of worker threads to send message to the Rollbar services asynchronously off the main thread.thread_pool_workers
to allow users control of the number of worker threads.0.16.4beta
. As this may need some tweaks/modifications before we go stable.Now all the considerations...
First, Python version compatibility. Using this requires a minimum of Python version of 3.2. However, depending on the version the behavior may be slightly different. This is because of how Python calculates the maximum number of workers (if the user did not specify it with
thread_pool_workers
). The calculation changed in 3.5 and 3.8 (see the docs on ThreadPoolExecutor for details).Second, stability. I had thought about updating the default handler to use a tread pool instead of creating a new thread for every message (that is what it currently does). However, this seems too early to make such a change. Any new handler should really be put through its paces under real world conditions, and ideally be used in production codebases for some time before we even consider changing the default.
Third, max workers. The default for
thread_pool_workers
isNone
. This is passed to themax_workers
argument forThreadPoolExecutor.__init__()
. I don't believe a default was added until Python 3.5. This means that our default may not work on versions 3.2 to 3.4. Users will likely need to explicitly set the number of workers. On more recent versionsNone
will cause Python to calculate it based on the number of CPUs (see the link to the docs above).Are we okay with the default not working on every version, or should we provide a different default on lower versions of Python?
Both the implementation and the tests are pretty minimal. If anyone thinks of anything that should also be tested let me know and I will add it. Feedback is very much appreciated!
Type of change
Related issues
Checklists
Development
Code review